#----------------------------------------------------------------------
#
# $Copyright: (c) 2009 Thomas Dejanovic.$
# 
#  This is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as
#  published by the Free Software Foundation; either version 2.1 of
#  the License, or (at your option) any later version.
# 
#  This software is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  Lesser General Public License for more details.
# 
#  You should have received a copy of the GNU Lesser General Public
#  License along with this software; if not, write to the Free
#  Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
#  02110-1301 USA, or see the FSF site: http://www.fsf.org.
#
#----------------------------------------------------------------------
#
#  This fragment runs hatch.
# 
#----------------------------------------------------------------------
id = "$Id: hatch.mak 667 2010-07-01 00:12:17Z jayshurtz $"
# $URL: http://hatch.googlecode.com/svn/tags/taggle_release_3.0/tools/makefiles/hatch.mak $
# $Author: jayshurtz $
#----------------------------------------------------------------------

targets ::
	@echo
	@echo "hatch.mak:"
	@echo "-----------"
	@echo
	@echo

#----------------------------------------------------------------------

HATCH_INCLUDED = 1

#----------------------------------------------------------------------

HATCH     = python ${HATCH_DIR}/hatch/hatch.py

HATCHLING_DIRS = . ${VERILOG_MODULE_DIRS}

HATCHLINGS := $(foreach dir,$(HATCHLING_DIRS),$(wildcard $(dir)/*_hatch.py))

HATCHLING_VERILOG = $(HATCHLINGS:%.py=%.v)
HATCHLING_DEFINES = $(HATCHLINGS:%.py=%.vh)
HATCHLING_TXT     = $(HATCHLINGS:%.py=%.txt)
HATCHLING_XML     = $(HATCHLINGS:%.py=%.xml)
HATCHLING_HTML    = $(HATCHLINGS:%.py=%.html)
HATCHLING_TARGETS = ${HATCHLING_VERILOG} \
		    ${HATCHLING_TXT} \
		    ${HATCHLING_XML} \
		    ${HATCHLING_HTML}


# tell any verilog makefile fragments that there is generated verilog
# available.
VERILOG_DEPENDS += ${HATCHLING_VERILOG}

HAL_HATCHLINGS = $(HATCHLINGS:%.py=%.hal)

.PHONY: txt
txt : ${HATCHLING_TXT}

.PHONY: xml
xml : ${HATCHLING_XML}

.PHONY: html
html : ${HATCHLING_HTML}

.PHONY: rtl
rtl : ${HATCHLING_VERILOG}



.PRECIOUS : %.vh
%_hatch.vh : %_hatch.v

.PRECIOUS : %.v
%_hatch.v : ${TOOL_DIR}/makefiles/hatch.mak %_hatch.py 
	rm -f $@
	cd `dirname $@` ; ${HATCH} --verilog `basename $*_hatch.py`

%_hatch.html : ${TOOL_DIR}/makefiles/hatch.mak %_hatch.py
	rm -f $@
	${HATCH} --html $*_hatch.py

%_hatch.xml : ${TOOL_DIR}/makefiles/hatch.mak %_hatch.py 
	rm -f $@
	${HATCH} --xml $*_hatch.py

%_hatch.txt : ${TOOL_DIR}/makefiles/hatch.mak %_hatch.py 
	rm -f $@
	${HATCH} --txt $*_hatch.py

%_hatched.py : ${TOOL_DIR}/makefiles/hatch.mak %_hatch.py
	rm -f $@
	${HATCH} --py $*_hatch.py

%_hatch.tex : ${TOOL_DIR}/makefiles/hatch.mak %_hatch.py 
	rm -f $@
	${HATCH} --latex $*_hatch.py

clobber ::
	rm -f ${HATCHLING_TARGETS} ${HATCHLING_DEFINES}

#----------------------------------------------------------------------
# Local Variables:
# mode: makefile
# End:
# End of initial.mak
